﻿<%@ Page  MasterPageFile="~/Site.Master" Language="C#" AutoEventWireup="true" CodeBehind="UserLogon.aspx.cs" Inherits="RabbitShop.UI.UserLogon" %>

<asp:Content runat="server" ID="BodyContent" ContentPlaceHolderID="MainContent">
    
    <form id="form1" action="../Action/Logon.aspx" method="POST">
        <hgroup class="title">
            <h2>User Logon</h2>
        </hgroup>
    
    <script type="text/javascript">
        form1.onsubmit = function (e) {
            // stop the regular form submission
            e.preventDefault();

            // collect the form data while iterating over the inputs
            var data = {};
            for (var i = 0, ii = form1.length; i < ii; ++i) {
                var input = form1[i];
                if (input.name) {
                    data[input.name] = input.value;
                }
            }

            // construct an HTTP request
            var xhr = new XMLHttpRequest();
            xhr.open(form1.method, form1.action, true);
            xhr.setRequestHeader('Content-Type', 'application/json; charset=UTF-8');

            // send the collected data as JSON
            xhr.send(JSON.stringify(data));

            xhr.onloadend = function () {
                // done
                if (xhr.responseText == "true") {
                    window.location = "UserDetail.aspx";
                } else {
                    alert(xhr.responseText);
                }
            };
        };
    </script>

    <table>
        <tr>
            <td>Name:</td>
            <td>
                <input type="text" id="inputName" name="Name"/>
            </td>
        </tr>
        
        <tr>
            <td>Password:</td>
            <td>
                <input type="password" id="inputPassword" name="Password"/>
            </td>
        </tr>

    </table>
    
        <input type="submit" value="登陆" />

    </form>


</asp:Content>